#include "../include/Configuration.h"
#include "../include/SplitToolCppjieba.h"
#include "../include/WebPage.h"
#include <iostream>
#include <string>
#include <map>
#include <set>

using std::cout;
using std::endl;
using std::string;
using std::map;
using std::set;
using std::ofstream;


// void testConf(){
    
//     Configuration* pconf = Configuration::getInstance();
//     auto config_map = pconf->getConfigMap();
//     //auto it = config_map.find("xml.web");
//     string path = config_map["xml_web"];
//     cout << path << endl;

//     auto stopWord_list = pconf->getStopWordList();
    
//     ofstream testfile("testRead.txt");

//     //测试_configMap内容
//     for(auto& it : config_map){
//         testfile << it.first << " " << it.second << endl;
//     }

//     //测试stopwords内容
//     for(auto& it2 : stopWord_list){
//         testfile << it2 << endl;
//     }

// } 

void testCppjieBa(){

    SplitToolCppjieba myJieBa;

    auto spiltWords = myJieBa.cut("<doc><id>1</docid> <url>http://baidu.com/</url> <title>博客榜—查看频道“中国互联网观察”</title> <content>博客榜—查看频道“中国互联网观察”…</content> </doc>");
    
    for(auto& it : spiltWords){
        cout << it << endl;
    }
}


void testWebpage(){
    const string doc1("<doc><docid>2</docid><url>url</url><title>title</title><content>content</content></doc>"); 
    const string doc2("<doc><docid>2</docid><url>url</url><title>title</title><content>content</content></doc>"); 

    Configuration* pconf = Configuration::getInstance();
    SplitToolCppjieba myJieBa;
    WebPage wp(doc1, *pconf, myJieBa);
    WebPage wp2(doc2, *pconf, myJieBa);

    // int Docid = wp.getDocId();
    // cout << Docid <<endl;


    wp.processDoc(doc1, *pconf, myJieBa);
    
    string Title = wp.getTitle();
    cout << Title << endl;

    string Url = wp.getUrl();
    cout << Url << endl;

    string Content = wp.getContent();
    cout << Content << endl;

    // bool flag = (wp == wp2);
    // cout<<  flag << endl;

}



int main(void){
    //testConf();
    //testCppjieBa();
    testWebpage();
    return 0;
}

